package com.open.capacity.user.controller;

import com.open.capacity.common.model.Title;
import com.open.capacity.common.model.TitleRule;
import com.open.capacity.common.web.PageResult;
import com.open.capacity.common.web.Result;
import com.open.capacity.user.service.TitleRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author liutao
 * @date 2021-02-23 09:33
 */
@RestController
@RequestMapping("/titleRule")
@Api(tags = "称号规则")
public class TitleRuleController {

    @Autowired
    private TitleRuleService titleRuleService;

    // 模糊查询称号规则
    @PostMapping("/getSelectTitleRules")
    @ApiOperation(value = "模糊查询称号")
    public PageResult<TitleRule> getSelectTitleRules(@RequestParam Map<String, Object> params){
        return titleRuleService.getSelectTitleRules(params);
    }

    // 添加称号规则
    @PostMapping("/addTitleRules")
    @ApiOperation(value = "添加称号")
    public Result addTitleRules(@RequestBody TitleRule titleRule){
        return titleRuleService.addTitleRules(titleRule);
    }

    // 修改称号规则
    @PostMapping("/updateTitleRules")
    @ApiOperation(value = "修改称号")
    public Result updateTitleRules(@RequestBody TitleRule titleRule){
        return titleRuleService.updateTitleRules(titleRule);
    }

    // 删除称号规则
    @DeleteMapping("/delTitleRules/{ttruid}")
    @ApiOperation(value = "删除称号")
    public Result delTitleRules(@PathVariable("ttruid") int ttruid){
        return titleRuleService.delTitleRules(ttruid);
    }

}
